package com.xiaoxin.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoxin.dubbo.mappers.SettingsMapper;
import com.xiaoxin.dubbo.mappers.UserMapper;
import com.xiaoxin.model.domain.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author xiaoxiaode
 * @date 2021-08-30-18:35
 **/
@DubboService
public class SettingServiceImpl implements SettingApi {

    @Autowired
    private SettingsMapper settingsMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    public Settings findByUserId(Long id) {
        QueryWrapper<Settings> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", id);
        return settingsMapper.selectOne(wrapper);
    }

    @Override
    public void save(Settings settings) {
        settingsMapper.insert(settings);
    }

    @Override
    public void update(Settings settings) {
        settingsMapper.updateById(settings);
    }

    // @Override
    // public String findPhone(Long id) {
    //     return  userMapper.findPhone(id);
    // }
}
